﻿using System;
using System.Linq;

namespace FacebookHackerCup2011
{
    /// <summary>
    /// http://habrahabr.ru/post/111898/
    /// </summary>
    public class FirstKvalification
    {
        /// <summary>
        /// Double Squares
        /// </summary>
        public static int Task1(int number)
        {
            int result = 0;

            int sqrt = (int)Math.Sqrt(number);
            for (int i = 0; i <= sqrt; i++)
            {
                for (int j = 0; j <= sqrt; j++)
                {
                    if (i * i + j * j == number)
                        result++;
                }
            }

            return (result+1)/2;
        }

        /// <summary>
        /// Studious Student
        /// </summary>
        public static string Task3(string sentence)
        {
            return string.Join("", sentence.Split(' ').OrderBy(x => x));
        }
    }
}
